#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Text;

namespace Osh.Dvb
{
	/// <summary>
	/// Summary description for ShortEventDescriptor.
	/// </summary>
	public class ShortEventDescriptor : Descriptor
	{
		private LanguageCode _languageCode;
		private string _eventName;
		private string _text;

		public ShortEventDescriptor(DescriptorReader reader, int length)
			: base(DescriptorTags.ShortEventDescriptor, length)
		{
			int languageCode = (int)reader.ReadUInt32BE();
			int eventNameLength = languageCode & 0xFF;
			languageCode >>= 8;
			_languageCode = (LanguageCode)languageCode;

			_eventName = TextEncoding.Default.GetString(reader.ReadBytes(eventNameLength), _languageCode);

			int textLength = reader.ReadByte();
			_text = TextEncoding.Default.GetString(reader.ReadBytes(textLength), _languageCode);
		}

		public LanguageCode LanguageCode
		{
			get { return _languageCode; }
		}
		public string EventName
		{
			get { return _eventName; }
		}
		public string Text
		{
			get { return _text; }
		}
	}
}
